package com.happyrecyclingstation.controller.admin;

import com.happyrecyclingstation.dto.CompanyQueryDto;
import com.happyrecyclingstation.entity.Company;
import com.happyrecyclingstation.service.CompanyService;
import com.happyrecyclingstation.utils.Result;
import com.happyrecyclingstation.vo.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员
 */
@Slf4j
@RestController("adminCompanyController")
@RequestMapping("/admin/companies")
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    /**
     * 分页查询获取公司
     * @param companyQueryDto
     * @return
     */
    @GetMapping("/all")
    public Result getAllCompanies(CompanyQueryDto companyQueryDto) {
        log.info("管理员公司列表：{}", companyQueryDto);
        PageResult<Company> companies = companyService.getAllCompanies(companyQueryDto);
        return Result.success(companies);
    }
}
